// type in the `man syscall` in your Linux systeml

// syscall - indirect system call
// Employing syscall() is useful, for example, when
// invoking a system call that has no wrapper function in the C library.

// syscall() saves CPU registers before making the system  call,  restores
// the  registers  upon  return from the system call, and stores any error
// returned by the system call in errno(3).

// Symbolic constants for system call numbers can be found in  the  header
// file <sys/syscall.h>.

#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <stdio.h>
#include <time.h>

int main()
{
    pid_t tid;
    clockid_t cpu_clock;
    struct timespec start,end;
    clock_getcpuclockid(0,&cpu_clock);
    clock_gettime(cpu_clock,&start);
    tid = syscall(SYS_getpid);
    clock_gettime(cpu_clock,&end);
    printf("%d used %ld ns + %lds \n",(int)tid,end.tv_nsec-start.tv_nsec
        ,(long)end.tv_sec - (long)start.tv_sec);
    return 0;
}

